package a66weding.com.jiehuntong.activity.home.hotel.hotelnew;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import org.xutils.x;

import java.util.List;

import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.activity.ShopDetailsActivity;
import a66weding.com.jiehuntong.adapter.MyBaseAdapter;
import a66weding.com.jiehuntong.beans.ShoplistBean;
import a66weding.com.jiehuntong.common.utils.ImageOptionsUtil;

/**
 * Created by admin on 2016/9/12.
 */
public class BusnessAdapter extends MyBaseAdapter {

    public BusnessAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        if (convertView==null){
            viewHolder = new ViewHolder();
            convertView = View.inflate(context, R.layout.item_findshop_shoplist,null);
            viewHolder.iv_lable_shop = (ImageView) convertView.findViewById(R.id.iv_lable_shop);
            viewHolder.tv_nvcName = (TextView) convertView.findViewById(R.id.tv_nvcName);
            viewHolder.tv_item_taocan = (TextView) convertView.findViewById(R.id.tv_item_taocan);
            viewHolder.tv_examplecount = (TextView) convertView.findViewById(R.id.tv_examplecount);
            viewHolder.tv_fensi = (TextView) convertView.findViewById(R.id.tv_fensi);
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }
        final ShoplistBean.DataBean dataBean = (ShoplistBean.DataBean) data.get(position);
        x.image().bind(viewHolder.iv_lable_shop,dataBean.getNvc_Logo(), ImageOptionsUtil.getcircle_fixy());
        viewHolder.tv_nvcName.setText(dataBean.getNvc_StoreName());
        //套餐
        viewHolder.tv_item_taocan.setText(""+dataBean.getProductCount());
        //案例数
        viewHolder.tv_examplecount.setText(""+dataBean.getCasesCount());
        //粉丝数
        viewHolder.tv_fensi.setText(""+dataBean.getBusinessMemberCount());
        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(context,ShopDetailsActivity.class);
                intent.putExtra("nvc_num",dataBean.getNvc_No());
                intent.putExtra("BusinessID",dataBean.getI_Id());
                context.startActivity(intent);
            }
        });
        return convertView;
    }

    class ViewHolder{
        //商家log
        ImageView iv_lable_shop;
        //商家名称
        TextView tv_nvcName;
        //套餐书
        TextView tv_item_taocan;
        //案例数
        TextView tv_examplecount;
        //粉丝数
        TextView tv_fensi;

    }
}
